package com.cgsrp.cgsrp_baby.controller;

import com.cgsrp.cgsrp_baby.domain.Vaccine;
import com.cgsrp.cgsrp_baby.service.VaccineService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("babyVaccine")
public class BabyVaccineController {
    @Autowired
    private VaccineService vaccineService;

    @GetMapping("list")
    public PageInfo<Vaccine> list(
            @RequestParam()int[] babyIds,
            @RequestParam(defaultValue = "1")Integer curPage,
            @RequestParam(defaultValue = "3")Integer pageSize
    ){
        return vaccineService.list(babyIds,curPage,pageSize);
    }

    @PostMapping("add")
    public boolean add(Vaccine vaccine){
        System.out.println("vaccine = " + vaccine);
        return vaccineService.insert(vaccine);
    }

    @PostMapping("del")
    public boolean del(int id){
        return vaccineService.deleteByPrimaryKey(id)>0;
    }

}
